#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
from util.app_global import version

if sys.platform in ['win32', 'cygwin', 'win64']:
    from esky.bdist_esky import Executable
    from distutils.core import setup
    data_files = [
        ('conf/logging.conf', 'conf/logging.conf'),
        ('tool_bin/mysqlbinlog_windows.exe', 'tool_bin/mysqlbinlog_windows.exe'),
        'lib/'
    ]

    #  We can custom the executable's creation by passing an instance
    #  of Executable() instead of just the script name.
    ui = Executable("UI.py",
                    #  give our app the standard Python icon
                    icon=os.path.join(sys.prefix, "DLLs", "py.ico"),
                    #  we could make the app gui-only by setting this to True
                    gui_only=True,
                    #  any other keyword args would be passed on to py2exe
                    )
    run = Executable("run.pyw", icon=os.path.join(sys.prefix, "DLLs", "py.ico"))

    setup(
        # data_files=data_files,
        name="bdp_sync",
        version=version,
        scripts=[ui, run],
        options={"bdist_esky": {
            #  forcibly include some other modules
            "includes": ["cloghandler", "pymssql", "DBUtils", "_mssql"],
            "excludes": ["pydoc"],
            #  force esky to freeze the app using cx_freeze
            "freezer_module": "cx_freeze",
            #  tweak the options used by cx_freeze
            "freezer_options": {
                'includeFiles': data_files
            },
            #  forcibly exclude some other modules
        }}
    )

if os.name == 'posix':
    from cx_Freeze import setup, Executable
    data_files = [
        ('conf/logging.conf', 'conf/logging.conf'),
    ]

    run = Executable("run.pyw")
    setup(
        # data_files=data_files,
        name="bdp_sync",
        version=version,
        executables=[run],
        options={"build_exe":{
            #  forcibly include some other modules
            "includes": ["cloghandler", "DBUtils"],
            #  forcibly exclude some other modules
            "excludes": ["pydoc"],
            'include_files': data_files
        }}
    )

